﻿<?php
	include '../inc/conn.php';
	session_start();
	extract($_POST);
	extract($_GET);
	unset($_POST,$_GET);
	
	if(!isset($_SESSION['logname'])){
		die("<div>User Session is missing</div>");
	}
	
	if (isset($act))
	{
		if (empty($imonth) || empty($ivalue)){
			echo "<script>alert('Some content must be filled in data!!');</script>";
			die("Some content must be filled in data!");
		}
		if ($act == 'add')
		{	
			date_default_timezone_set('Asia/Shanghai');
			$dyear = date("Y");
			$db = new mysql();
			$sql="INSERT INTO `eng_kpi` (`UID`, `KPI_year`, `KPI_month`, `KPI_total`) values ($id, $dyear, $imonth, $ivalue);";
			$db->query($sql);
			$db->close();
			echo "<script>alert('Data added!');window.opener.location.reload();window.close();</script>";
		}
	}
?>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- <link rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/css/bootstrap.min.css">-->
<link rel="stylesheet" href="/css/bootstrap.min.css">
<script type="text/javascript" src="/js/jquery.min.js"></script>
<script type="text/javascript" src="/js/jquery-migrate.min.js"></script>
<script type="text/javascript" src="/js/bootstrap.min.js"></script>
<style>
<!--
.xheDialog label {
	display: inline;
}
.form-horizontal .control-label {
	width: 80px;
}
.form-horizontal .controls {
	margin-left: 20px;
}
-->
</style>
<title>新增绩效</title>
</head>
<body class="background">
<div class="container white-background pagecontent">
	<form action="add_kpi.php?act=add&id=<? echo $id ?>" method="post">
	<div>
	<div class="input-group">
	<span class="input-group-addon">年份:</span><input name="iyear" type="text" class="form-control" value="<? echo date("Y"); ?>">
	<span class="input-group-addon">月份:</span><input name="imonth" type="text" class="form-control" value="<? if (isset($imonth)) echo $imonth; else echo date("m"); ?>">
	</div>
		<div class="input-group">
	<span class="input-group-addon">得分:</span><input name="ivalue" type="text" class="form-control" value="60">
		</div>
	</div>
	<div><input class="btn btn-success btn-primary" name="submit" value="提交" type="submit"><input class="btn btn-danger" name="reset" value="重填" type="reset"></div>
	</form>
</div>
</body>
</html>
